//
//  OuterInnerViewController.m
//  CoreAnimationDemo
//
//  Created by 王亮 on 2017/8/9.
//  Copyright © 2017年 王亮. All rights reserved.
//

#import "OuterInnerViewController.h"

@interface OuterInnerViewController ()

@property (nonatomic, strong)UIView *outerView;
@property (nonatomic, strong)UIView *innerView;

@end

@implementation OuterInnerViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    self.outerView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 200, 200)];
    self.outerView.backgroundColor = [UIColor grayColor];
    self.outerView.center = self.view.center;
    [self.view addSubview:self.outerView];
    
    self.innerView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 100, 100)];
    self.innerView.backgroundColor = [UIColor whiteColor];
    self.innerView.center = CGPointMake(100, 100);
    [self.outerView addSubview:self.innerView];
    
    CATransform3D outer = CATransform3DIdentity;
    outer.m34 = -1.0/500.0;
    outer = CATransform3DRotate(outer, M_PI_4, 0, 1, 0);
    self.outerView.layer.transform = outer;
    CATransform3D inner = CATransform3DIdentity;
    inner.m34 = -1.0/500.0;
    inner = CATransform3DRotate(inner, -M_PI_4, 0, 1, 0);
    self.innerView.layer.transform = inner;
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
